<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">错误日志</ui:define>
    <ui:define name="content">

        <h:form>

            <p:dialog id="errorLogDetailPanel" rendered="#{errorLogListBean.$.currentErrorLogDetail != null}" header="异常详情" position="center" widgetVar="errorLogDetail" modal="true" width="60%" height="90%">
                <p:scrollPanel style="width:100%;height:500px;border:0px">
                    <p:panelGrid columns="2"
                                 columnClasses="ui-grid-col-2,ui-grid-col-10"
                                 layout="grid" styleClass="ui-panelgrid-blank"
                                 style="border:0px none; background-color:transparent;">
                        <p:outputLabel for="detailProjectName" value="所属项目"/>
                        <p:inputText id="detailProjectName" value="#{errorLogListBean.$.currentErrorLogDetail.projectName}" style="width:100%"/>
                        <p:outputLabel for="detailException" value="异常名称"/>
                        <p:inputText id="detailException" value="#{errorLogListBean.$.currentErrorLogDetail.exception}"  style="width:100%"/>
                        <p:outputLabel for="detailFirstStack" value="首行异常"/>
                        <p:inputText id="detailFirstStack" value="#{errorLogListBean.$.currentErrorLogDetail.firstStack}"  style="width:100%"/>
                        <p:outputLabel for="detailMsg" value="异常信息"/>
                        <p:inputTextarea id="detailMsg" value="#{errorLogListBean.$.currentErrorLogDetail.msg}" style="width:100%"/>
                        <p:outputLabel for="detailStackTrack" value="异常堆栈"/>
                        <p:inputTextarea id="detailStackTrack" value="#{errorLogListBean.$.currentErrorLogDetail.stackTrack}"  style="width:100%"/>

                    </p:panelGrid>
                </p:scrollPanel>
            </p:dialog>

            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton value="刷新数据" icon="fa fa-flash"
                                         actionListener="#{errorLogListBean.onRefresh}"
                                         process="@this" update="@form"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"/>

                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         actionListener="#{errorLogListBean.onReset}"
                                         process="@this"
                                         update="@form"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="6" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-3"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;text-align:center;">

                                <p:outputLabel for="projectName" value="工程名称"/>
                                <p:selectOneMenu id="projectName" value="#{errorLogListBean.$.projectName}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{errorLogListBean.projectNames}"
                                            var="projectName"
                                            itemLabel="#{projectName}" itemValue="#{projectName}"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="startTime" value="开始时间"/>
                                <p:calendar id="startTime" value="#{errorLogListBean.$.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>

                                <p:outputLabel for="endTime" value="结束时间"/>
                                <p:calendar id="endTime" value="#{errorLogListBean.$.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>

                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="errorLogDataTable"
                                         style="width: 100%"
                                         var="errorLog"
                                         value="#{errorLogListBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         reflow="true"
                                         selection="#{errorLogListBean.selectedRecords}"
                                         resizableColumns="true">

                                <p:column headerText="操作" rendered="#{errorLogListBean.isNotBatch()}" style="width:70px;">
                                    <p:splitButton icon="fa fa-eye"
                                                   actionListener="#{errorLogListBean.getDetail(errorLog.logId)}"
                                                   oncomplete="PF('errorLogDetail').show()"
                                                   process="@this" update="@form">
                                        <p:menuitem value="标记已经处理" icon="fa fa-check"
                                                    action="#{errorLogListBean.onChecked(errorLog)}"
                                                    process="@this" update="@form"/>
                                    </p:splitButton>
                                </p:column>
                                <p:column selectionMode="multiple" style="width:16px;text-align:center"
                                          rendered="#{errorLogListBean.isBatch()}"/>
                                <p:column headerText="产生时间" style="width:80px">
                                    <h:outputText value="#{errorLog.createTimeStr}"/>
                                </p:column>
                                <p:column headerText="工程名称" style="width:160px">
                                    <h:outputText value="#{errorLog.projectName}"/>
                                </p:column>
                                <p:column headerText="第一行异常">
                                    <h:outputText value="#{errorLog.firstStack}"/>
                                </p:column>
                                <p:column headerText="出现次数" style="width:60px;text-align:center">
                                    <h:outputText value="#{errorLog.count}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
